<%@page contentType="text/html;charset=UTF-8" language="java"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Date"%>
<%@page import="javax.jdo.PersistenceManager"%>
<%@page import="javax.jdo.Query"%>
<%@page import="de.upb.messerschmidt.set.entity.Talk"%>
<%@page import="de.upb.messerschmidt.set.entity.Room"%>
<%@page import="de.upb.messerschmidt.set.entity.Person"%>
<%@page import="de.upb.messerschmidt.set.jdo.PMF"%>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Talk Registration</title>
</head>

<body>
	<h1>Talk Registration</h1>
	<p>Please enter the talk information and submit by pressing the
		button</p>
	<form action="post/attend/talk" method="post">
		<!-- Locations mit JSP abrufen -->
		<table>
			<tr>
				<td>Talk:</td>
				<td><select name="talk" size="1">
						<%
							PersistenceManager pm = PMF.get().getPersistenceManager();
							Query query = pm.newQuery(Talk.class);
							query.setOrdering("topic desc");
							try {
								@SuppressWarnings("unchecked")
								List<Talk> talks = (List<Talk>) query.execute();
								if (!talks.isEmpty()) {
									for (Talk t : talks) {
						%>
						<option>
							<%=t.getTopic() + " at " + t.getEvent()%>
						</option>
						<%
							}
								}
							}

							catch (Exception e) {
								e.printStackTrace();
							}
						%>
				</select>
				</td>
			</tr>
			<tr>
				<td>Person:</td>
				<td><select name="person" size="1">
						<%
							Query personQuery = pm.newQuery(Person.class);
							personQuery.setOrdering("name desc");
							try {
								@SuppressWarnings("unchecked")
								List<Person> persons = (List<Person>) personQuery.execute();
								if (!persons.isEmpty()) {
									for (Person p : persons) {
						%>
						<option>
							<%=p.getName() + ", " + p.getPrename()%>
						</option>
						<%
							}
								}
							}

							catch (Exception e) {
								e.printStackTrace();
							}
						%>
				</select>
				</td>
			</tr>
			<tr>
				<td><input type="submit" value="Submit" />
				</td>
				<td><input type="reset" value="Reset">
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
